﻿using System;
using Unity.Connections;
using Unity.Credentials;

namespace Unity.Debug
{
    public class ConsoleUnityProducerFactory : IUnityConnectionFactory
    {
        public bool IsSupportPull()
        {
            return false;
        }

        public bool IsSupportPush()
        {
            return true;
        }

        public IUnityProducer NewProducer(IUnityCredentials credentials)
        {
            if (!credentials.GetType().IsSubclassOf(typeof(IUnityCredentials)))
            {
            //    throw new Exception("not applicable credential type");
            }

            return new ConsoleUnityProducer((ConsoleUnityCredentials)credentials);
        }

        public IUnityConsumer NewPullConsumer(IUnityCredentials credentials)
        {
            throw new NotImplementedException();
        }

        public IUnityConsumer NewPushConsumer(IUnityCredentials credentials, IUnityCallback callback)
        {
            if (!credentials.GetType().IsSubclassOf(typeof(IUnityCredentials)))
            {
             //   throw new Exception("not applicable credential type");
            }

            return new ConsoleUnityConsumer((ConsoleUnityCredentials)credentials, callback);
        }
        
    }
}